package com.dao.impl;

import com.bean.Evaluate;
import com.dao.EvaluateDao;

import java.util.List;
import java.util.Map;

public class EvaluateDaoImpl extends BaseDao implements EvaluateDao {

    @Override
    public int saveEvaluate(Evaluate evaluate) {
        String sql="insert into evaluate(`content`,`createtime`,`orderitemid`,`userid`,`flowerid`,`enterpriseid`)values(?,?,?,?,?,?)";
        return update(sql,evaluate.getContent(),evaluate.getCreatetime(),evaluate.getOrderitemid(),evaluate.getUserid(),evaluate.getFlowerid(),evaluate.getEnterpriseid());
    }

    @Override
    public List<Evaluate> querymyEvaluate(String id) {
        String sql="select `id`,`content`,`createtime`,`orderitemid`,`userid`,`flowerid`,`enterpriseid` from evaluate where userid=? order by id DESC";
        return queryForList(Evaluate.class,sql,id);
    }

    @Override
    public List<Evaluate> queryByFlowerid(Integer flowerid) {
        String sql="select `id`,`content`,`createtime`,`orderitemid`,`userid`,`flowerid`,`enterpriseid` from evaluate where flowerid=? order by id DESC";
        return queryForList(Evaluate.class,sql,flowerid);

    }

    @Override
    public List<Map<String, Object>> listMyEvaluate(String id) {
        String sql="select * from evaluate,flower_detail where userid=? and evaluate.flowerid=flower_detail.flowerid order by id DESC";
        return listquery(Evaluate.class,sql,id);
    }
}
